package com.cius.ssm.controller;

import com.cius.ssm.entity.ProductAndUser;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Json格式测试
 * Created by ciuscheung on 17/4/11.
 */

@Controller
public class JsonTest {

    //请求Json串(商品信息),输出json(商品信息)
    //@RequestMapping将请求的商品信息的json串转成ProductAndUser对象
    //@ResponseBody将productAndUser转换成json格式输出
    @RequestMapping("/requestJson")
    public @ResponseBody ProductAndUser requestJson(@RequestBody ProductAndUser productAndUser){
//        @ResponseBody将productAndUser转换成json格式
        return productAndUser;
    }

    //请求key/value(商品信息),输出json(商品信息)
    @RequestMapping("/responseJson")
    public @ResponseBody ProductAndUser responseJson(ProductAndUser productAndUser){
//        @ResponseBody将productAndUser转换成json格式
        return productAndUser;
    }

}
